package com.wujilin.okra.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * The Okra database.
 * 
 * @author Belin Wu
 *
 */
public class OkraDatabase extends SQLiteOpenHelper {
	/**
	 * The database file name.
	 */
	private static final String NAME = "okra";
	
	/**
	 * The database version currently.
	 */
	private static final int VERSION = 1;
	
	private static final String CREATE_OBJECTIVE = "create table objective ( " + 
			"_id integer primary key autoincrement not null, " + 
			"category_id integer, " + 
			"content text not null, " + 
			"year integer not null, " + 
			"quarter integer not null, " + 
			"grade real default 0.0, " + 
			"time text not null)";
	
	private static final String CREATE_KEY_RESULT = "create table key_result ( " + 
			"_id integer primary key autoincrement not null, " + 
			"objective_id integer not null, " + 
			"content text not null, " + 
			"grade real default 0.0, " + 
			"time text not null)";
	
	private static final String CREATE_CATEGORY = "create table category ( " + 
			"_id integer primary key autoincrement not null, " + 
			"name text not null)";

	public OkraDatabase(Context context) {
		super(context, NAME, null, VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_OBJECTIVE);
		db.execSQL(CREATE_KEY_RESULT);
		db.execSQL(CREATE_CATEGORY);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		
	}
}
